package xixirupan.tmgp.tencent.com.vmeim.login.Model;

import android.util.Log;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import xixirupan.tmgp.tencent.com.vmeim.config.URLConfig;
import xixirupan.tmgp.tencent.com.vmeim.retrofit.IRegistorR;

/**
 * Created by lenovo on 2016/10/21.
 */

public class CountryBiz {
    ICountryData iCountryData;
    public void getData(final ICountryData iCountryData)
    {
        this.iCountryData =iCountryData;
        Retrofit retrofit =new Retrofit.Builder().baseUrl(URLConfig.Url.BASE_URL)
                .addConverterFactory(GsonConverterFactory.create()).build();
        IRegistorR iRegistorR = retrofit.create(IRegistorR.class);
        Call<CountryBean> call = iRegistorR.getCountryData();
        call.enqueue(new Callback<CountryBean>() {
            @Override
            public void onResponse(Call<CountryBean> call, Response<CountryBean> response) {
                CountryBean body = response.body();
                DataBaen data = body.getData();
                List<CountriesBaen> countries = data.getCountries();
                Log.i("注册下面的数据下载成功：","=========>"+countries.size());
                iCountryData.postCountryData(countries);
            }

            @Override
            public void onFailure(Call<CountryBean> call, Throwable t) {
                Log.i("注册下面的数据下载失败：","=========>"+t.getMessage());
            }
        });
    }

}
